//
//  DZSpeedReportCell.m
//  dzyc
//
//  Created by 蓝鳍互娱 on 2024/6/18.
//

#import "DZSpeedReportCell.h"

static NSString * DZSpeedReportCellId = @"DZSpeedReportCellId";
@interface DZSpeedReportCell()
@property (nonatomic,strong) UIView *speedReportHeadView;
@property (nonatomic,strong) UILabel *speedReportHeadLab;
@property (nonatomic,strong) UILabel *speedReportDressLab;
@property (nonatomic,strong) UILabel *speedReportLocalLab;
@property (nonatomic,strong) UILabel *speedReportTimeLab;
@property (nonatomic,strong) UILabel *speedReportLongLab;
@end
@implementation DZSpeedReportCell
+ (instancetype)showSpeedReportCell:(UITableView *)tableView{
    DZSpeedReportCell * speedReportCell = [tableView dequeueReusableCellWithIdentifier:DZSpeedReportCellId];
    if (!speedReportCell) {
        speedReportCell = [[DZSpeedReportCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:DZSpeedReportCellId];
    }
    speedReportCell.backgroundColor = [UIColor clearColor];
    speedReportCell.selectionStyle = UITableViewCellSelectionStyleNone;
    speedReportCell.accessoryType = UITableViewCellAccessoryNone;
    return speedReportCell;
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self == [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self makeSubView];
    }
    return self;
}
- (void)makeSubView{
    self.speedReportHeadView = [[UIView alloc] init];
    self.speedReportHeadView.layer.cornerRadius = DZRatio(50);
    self.speedReportHeadView.clipsToBounds = YES;
    [self.contentView addSubview:self.speedReportHeadView];
    [self.speedReportHeadView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@(DZRatio(40)));
        make.centerY.equalTo(self.contentView);
        make.height.equalTo(@(DZRatio(100)));
        make.width.equalTo(@(DZRatio(100)));
    }];
    self.speedReportHeadLab = [[UILabel alloc] init];
    self.speedReportHeadLab.font = [UIFont systemFontOfSize:DZRatio(42) weight:UIFontWeightBold];
    self.speedReportHeadLab.textColor = DZHex(@"#F4FFF4");
    self.speedReportHeadLab.textAlignment = NSTextAlignmentCenter;
    [self.speedReportHeadView addSubview:self.speedReportHeadLab];
    [self.speedReportHeadLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(@(DZRatio(0)));
    }];
    self.speedReportDressLab = [[UILabel alloc] init];
    self.speedReportDressLab.font = [UIFont systemFontOfSize:DZRatio(36) weight:UIFontWeightBold];
    self.speedReportDressLab.textColor = DZHex(@"#222222");
    [self addSubview:self.speedReportDressLab];
    [self.speedReportDressLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.speedReportHeadView.mas_right).offset(DZRatio(27));
        make.top.equalTo(@(DZRatio(17)));
        make.height.equalTo(@(DZRatio(50)));
    }];
    self.speedReportLocalLab = [[UILabel alloc] init];
    self.speedReportLocalLab.font = [UIFont systemFontOfSize:DZRatio(26) weight:UIFontWeightRegular];
    self.speedReportLocalLab.textColor = DZHex(@"#666666");
    [self addSubview:self.speedReportLocalLab];
    [self.speedReportLocalLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.speedReportHeadView.mas_right).offset(DZRatio(27));
        make.top.equalTo(self.speedReportDressLab.mas_bottom).offset(DZRatio(11));
        make.height.equalTo(@(DZRatio(36)));
    }];
    self.speedReportTimeLab = [[UILabel alloc] init];
    self.speedReportTimeLab.font = [UIFont systemFontOfSize:DZRatio(26) weight:UIFontWeightRegular];
    self.speedReportTimeLab.textColor = DZHex(@"#666666");
    [self addSubview:self.speedReportTimeLab];
    [self.speedReportTimeLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.speedReportHeadView.mas_right).offset(DZRatio(27));
        make.top.equalTo(self.speedReportLocalLab.mas_bottom).offset(DZRatio(4));
        make.height.equalTo(@(DZRatio(36)));
    }];
    self.speedReportLongLab = [[UILabel alloc] init];
    self.speedReportLongLab.font = [UIFont systemFontOfSize:DZRatio(26) weight:UIFontWeightRegular];
    self.speedReportLongLab.textColor = DZHex(@"#666666");
    [self addSubview:self.speedReportLongLab];
    [self.speedReportLongLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.speedReportHeadView.mas_right).offset(DZRatio(27));
        make.top.equalTo(self.speedReportTimeLab.mas_bottom).offset(DZRatio(4));
        make.height.equalTo(@(DZRatio(36)));
    }];
}
-(void)setSpeedReportShuJuMdl:(DzSpeedReportShuJuModel *)speedReportShuJuMdl{
    _speedReportShuJuMdl = speedReportShuJuMdl;
    DZWeakSelf
    if(_speedReportShuJuMdl){
        if([_speedReportShuJuMdl.M floatValue] < 4){
            self.speedReportHeadView.backgroundColor = DZHex(@"#62CC53");
        }else if([_speedReportShuJuMdl.M floatValue] < 5){
            self.speedReportHeadView.backgroundColor = DZHex(@"#4AA3C8");
        }else{
            self.speedReportHeadView.backgroundColor = DZHex(@"#EF8534");
        }
        self.speedReportHeadLab.text = _speedReportShuJuMdl.M;
        self.speedReportDressLab.text = _speedReportShuJuMdl.LOCATION_C;
        [NSString getLocationForGeocoder:[_speedReportShuJuMdl.EPI_LAT doubleValue] longitude:[_speedReportShuJuMdl.EPI_LON doubleValue] scurssBlock:^(NSString * _Nonnull locationName) {
            weakSelf.speedReportLocalLab.text = [NSString stringWithFormat:@"坐标:%@%@",weakSelf.speedReportShuJuMdl.LOCATION_C,locationName];
        }];
        self.speedReportTimeLab.text = [NSString stringWithFormat:@"时间:%@",_speedReportShuJuMdl.SAVE_TIME];
        self.speedReportLongLab.text = [NSString stringWithFormat:@"深度:%@公里",_speedReportShuJuMdl.EPI_DEPTH];
    }
}
@end
